package com.kanshu.ksgb.fastread.doudou.common.net.bean;

import com.kanshu.ksgb.fastread.doudou.R;
import com.kanshu.ksgb.fastread.doudou.app.Xutils;
import com.kanshu.ksgb.fastread.doudou.common.business.utils.UserUtils;
import com.kanshu.ksgb.fastread.doudou.common.util.JsonUtils;
import com.kanshu.ksgb.fastread.doudou.common.util.MD5Util;
import com.kanshu.ksgb.fastread.doudou.common.util.Utils;

import java.util.Random;

public class DeviceRequestParams {
    public String device_id;
    public String req_time;
    public String app_key;
    public String app_token;
    public String user_id;
    // 书库版本 到时看后台配置
    public String version;
    // 后台分配给客户端的appid
    public String app_id;
    // 渠道id
    public String channel_id;
    // app版本标识
    public String version_name;

    public DeviceRequestParams() {
        device_id = UserUtils.getDeviceId();
        req_time = System.currentTimeMillis() + "" + (new Random().nextInt(8999) + 1000);
        app_key = Xutils.getContext().getResources().getString(R.string.app_key);
        app_token = MD5Util.md5(device_id + "#" + req_time + "#" + Xutils.getContext().getResources().getString(R.string.app_secret));
        app_id = Xutils.getContext().getString(R.string.app_id);
        version = Xutils.getContext().getString(R.string.version);
        channel_id = UserUtils.getChannelId();
        version_name = Utils.getVersionName(Xutils.getContext());
    }
    public String toJsonStr() {
        return JsonUtils.bean2Json(this);
    }
}
